<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="学号" prop="studentNo">
        <el-input
          v-model="queryParams.studentNo"
          placeholder="请输入学号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学生姓名" prop="studentName">
        <el-input
          v-model="queryParams.studentName"
          placeholder="请输入学生姓名"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号" prop="cellNo">
        <el-input
          v-model="queryParams.cellNo"
          placeholder="请输入手机号"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <div v-if="highQueryFlag">
        <el-form-item label="校区" prop="campusId">
          <treeselect style="width:200px" v-model="queryParams.campusId" :options="campusOptions" 
                :multiple="false" :disableBranchNodes="true"
                :select="selectOthers"
                :show-count="true" placeholder="请选择归属校区" />
        </el-form-item>

      <el-form-item label="学校" prop="schoolId">
        <el-select
              v-model="queryParams.schoolId"
              placeholder="请选择学校"
              clearable
              size="small"
              style="width: 200px"
            >
              <el-option
                v-for="school in schoolOptions"
                :key="school.schoolId"
                :label="school.schoolName"
                :value="school.schoolId"
              />
            </el-select>
      </el-form-item>
      
      <el-form-item label="班级" prop="classId">
        <el-select
              v-model="queryParams.classId"
              placeholder="请选班级"
              clearable
              size="small"
              style="width: 200px"
            >
              <el-option
                v-for="classInfo in classOptions"
                :key="classInfo.classId"
                :label="classInfo.className"
                :value="classInfo.classId"
              />
            </el-select>
      </el-form-item>
      <el-form-item label="年级" prop="grade">
        <el-input
          v-model="queryParams.grade"
          placeholder="请输入年级"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="科别" prop="subjectType">
        <el-select v-model="queryParams.subjectType" placeholder="请选择科别" clearable size="small">
          <el-option
                  v-for="dict in subjectTypeOptions"
                  :key="dict.dictValue"
                  :label="dict.dictLabel"
                  :value="dict.dictValue"
                ></el-option>
        </el-select>
      </el-form-item>
      <!--
      <el-form-item label="营销来源" prop="marketingSource">
        <el-input
          v-model="queryParams.marketingSource"
          placeholder="请输入营销来源"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      -->
      <el-form-item label="招生员" prop="recruitUserId">
        <el-select
              v-model="queryParams.recruitUserId"
              placeholder="请选招生员"
              clearable
              size="small"
              style="width: 200px"
            >
              <el-option
                v-for="user in recruitUserOptions"
                :key="user.userId"
                :label="user.nickName"
                :value="user.userId"
              />
            </el-select>
      </el-form-item>
      <el-form-item label="缴费类型" prop="payType">
        <el-select v-model="queryParams.payType" placeholder="请选择缴费类型" clearable size="small">
          <el-option
                v-for="dict in payTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      <el-form-item label="缴费状态" prop="payStatus">
        <el-select v-model="queryParams.payStatus" placeholder="请选择缴费状态" clearable size="small">
          <el-option
                v-for="dict in payStatusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      <!--
      <el-form-item label="学习状态" prop="trainType">
        <el-select v-model="queryParams.trainType" placeholder="请选择学习状态" clearable size="small">
          <el-option
                v-for="dict in trainTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      <el-form-item label="学员状态" prop="studentType">
        <el-select v-model="queryParams.studentType" placeholder="请选择学员状态" clearable size="small">
          <el-option
                v-for="dict in studentTypeOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      <el-form-item label="帐号状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择帐号状态" clearable size="small">
          <el-option
                v-for="dict in statusOptions"
                :key="dict.dictValue"
                :label="dict.dictLabel"
                :value="dict.dictValue"
              />
        </el-select>
      </el-form-item>
      -->
      </div>
      <el-form-item>
        <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        <el-button :icon="highQueryIcon" size="mini" @click="highQuery">高级查询</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['edu:student:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['edu:student:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['edu:student:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['edu:student:export']"
        >导出</el-button>
      </el-col>
      <!--
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleUpgrade"
          v-hasPermi="['edu:student:edit']"
        >升班</el-button>
      </el-col>
      -->
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleClassStepIn"
          v-hasPermi="['edu:student:edit']"
        >插班/换班</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="multiple"
          @click="handleGraduate"
          v-hasPermi="['edu:student:edit']"
        >结业</el-button>
      </el-col>
	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="studentList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <!-- <el-table-column v-if="false" label="学生ID" align="center" prop="studentId" /> -->
      <el-table-column label="学号" align="center" prop="studentNo" width="100px" />
      <el-table-column label="学生姓名" align="center" width="100px" >
        <template slot-scope="scope">
          <el-link
            type="primary"
            :underline="false"
            style="font-size: 13px; font-weight: normal"
            @click="handleReference(scope.row)"
          >
            {{ scope.row.studentName }}
          </el-link>
        </template>
      </el-table-column>
      <el-table-column label="学校" align="center" prop="schoolName" width="150px" />
      <el-table-column label="学院" align="center" prop="collegeName" width="150px" />
      <el-table-column label="专业" align="center" prop="majorName" width="150px" />
      <!-- <el-table-column label="班级" align="center" prop="className" width="150px" />
      <el-table-column label="年级" align="center" prop="grade" width="100px" />
      <el-table-column label="科别" :formatter="subjectTypeFormat" width="100px" align="center" prop="subjectType" /> -->
      <el-table-column label="身份证号" align="center" prop="idNo" width="160px" />
      <!--
      <el-table-column label="身份证正面" align="center" prop="idFrontUrl" />
      <el-table-column label="身份证背面" align="center" prop="idBackUrl" />
      -->
      <!-- <el-table-column label="民族" :formatter="nationFormat" align="center" prop="nation" width="100px" /> -->
      <el-table-column label="手机号" align="center" prop="cellNo" width="120px" />
      <!-- <el-table-column label="QQ号" align="center" prop="qqNo" width="100px" />
      <el-table-column label="用户邮箱" align="center" prop="email" width="150px" /> -->
      <el-table-column label="用户性别" :formatter="sexFormat" align="center" prop="sex" width="100px" />
      <!--
      <el-table-column label="头像地址" align="center" prop="avatar" />
      -->
      <!-- <el-table-column label="详细地址" align="center" prop="addr" width="100px" /> -->
      <!--
      <el-table-column label="紧急联系人" align="center" prop="urgentPerson" width="100px" />
      <el-table-column label="紧急联系电话" align="center" prop="urgentCellNo" width="100px" />
      -->
      <!-- <el-table-column label="营销来源" align="center" prop="marketingSource" width="100px" />
      <el-table-column label="招生员" align="center" prop="recruitUserName" width="100px" />
      <el-table-column label="录入人" align="center" prop="inputUserName" width="100px" />
      <el-table-column label="审核人" align="center" prop="auditUserName" width="100px" /> -->
      <el-table-column label="报到日期" align="center" prop="registDate" width="180px">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.registDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="缴费类型" :formatter="payTypeFormat" align="center" prop="payType" width="100px" />
      <el-table-column label="缴费状态" :formatter="payStatusFormat" align="center" prop="payStatus" width="100px" />
      <el-table-column label="分期数" align="center" prop="stageNum" width="100px" />
      <el-table-column label="分期金额" align="center" prop="stageAmount" width="100px" />
      <el-table-column label="学习状态" :formatter="trainTypeFormat" align="center" prop="trainType" width="100px" />
      <!-- <el-table-column label="学员状态" :formatter="studentTypeFormat" align="center" prop="studentType" width="100px" />
      <el-table-column label="帐号状态" :formatter="statusFormat" align="center" prop="status" width="100px" /> -->
      <!--
      <el-table-column label="最后登录IP" align="center" prop="loginIp" />
      <el-table-column label="最后登录时间" align="center" prop="loginDate" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.loginDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      -->
      <el-table-column label="操作" fixed="right" min-width="240px" align="center">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['edu:student:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-hasPermi="['edu:student:edit']"
          ><router-link :to="'/signInfo/sign/index/' + scope.row.studentId" class="link-type">
            <span>报名</span>
          </router-link></el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            v-hasPermi="['edu:student:edit']"
          ><router-link :to="'/attendanceInfo/attendance/index/' + scope.row.studentId" class="link-type">
            <span>考勤</span>
          </router-link></el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['edu:student:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生（客户）信息对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-tabs v-model="activeName" @tab-click="handleTabChange">
          <el-tab-pane label="基本信息" name="first">
            <el-row>
              <el-col :span="12">
                <el-form-item label="学号" prop="studentNo">
                  <el-input disabled v-model="form.studentNo" placeholder="请输入学号" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="学生姓名" prop="studentName">
                  <el-input v-model="form.studentName" placeholder="请输入学生姓名" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="用户性别" prop="sex">
                  <el-select v-model="form.sex" placeholder="请选择性别">
                    <el-option
                        v-for="dict in sexOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="头像地址" prop="avatar">
                  <el-input v-model="form.avatar" placeholder="请输入头像地址" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="详细地址" prop="addr">
                  <el-input v-model="form.addr" placeholder="请输入详细地址" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="紧急联系人" prop="urgentPerson">
                  <el-input v-model="form.urgentPerson" placeholder="请输入紧急联系人" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="紧急联系电话" prop="urgentCellNo">
                  <el-input v-model="form.urgentCellNo" placeholder="请输入紧急联系电话" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <!--
                <el-form-item label="营销来源" prop="marketingSource">
                  <el-input v-model="form.marketingSource" placeholder="请输入营销来源" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                -->
                <el-form-item label="招生员" prop="recruitUserId">
                  <el-select
                    v-model="form.recruitUserId"
                    placeholder="请选招生员"
                    clearable
                    size="small"
                    style="width: 200px"
                  >
                    <el-option
                      v-for="user in recruitUserOptions"
                      :key="user.userId"
                      :label="user.nickName"
                      :value="user.userId"
                    />
                  </el-select>
                </el-form-item>
              </el-col>
              <!--
              <el-col :span="12">
                <el-form-item label="报到日期" prop="registDate">
                  <el-date-picker clearable size="small" style="width: 200px"
                    v-model="form.registDate"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择报到日期">
                  </el-date-picker>
                </el-form-item>
              </el-col>
              -->
            </el-row>
            
            
            <!--
            <el-row>
              <el-col :span="12">
                <el-form-item label="审核人ID" prop="auditUserId">
                  <el-input v-model="form.auditUserId" placeholder="请输入审核人ID" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="录入人ID" prop="inputUserId">
                  <el-input v-model="form.inputUserId" placeholder="请输入录入人ID" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-form-item label="最后登录IP" prop="loginIp">
              <el-input v-model="form.loginIp" placeholder="请输入最后登录IP" />
            </el-form-item>
            <el-form-item label="最后登录时间" prop="loginDate">
              <el-date-picker clearable size="small" style="width: 200px"
                v-model="form.loginDate"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择最后登录时间">
              </el-date-picker>
            </el-form-item>
            -->
          </el-tab-pane>
          <el-tab-pane label="原学校信息" name="second">
            <el-row>
              <el-col :span="12">
                <el-form-item label="校区" prop="campusIdForm">
                  <treeselect style="width:200px" v-model="campusIdForm" :options="campusOptions" 
                        :multiple="false" :disableBranchNodes="true"
                        :select="selectOthers"
                        :show-count="true" placeholder="请选择归属校区" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="学校" prop="schoolId">
                  <el-select
                      v-model="form.schoolId"
                      placeholder="请选择学校"
                      clearable
                      size="small"
                      style="width: 200px"
                    >
                      <el-option
                        v-for="school in schoolOptions"
                        :key="school.schoolId"
                        :label="school.schoolName"
                        :value="school.schoolId"
                      />
                    </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="学院" prop="collegeId">
                  <el-select
                      v-model="form.collegeId"
                      placeholder="请选择学院"
                      clearable
                      size="small"
                      style="width: 200px"
                    >
                      <el-option
                        v-for="college in collegeOptions"
                        :key="college.collegeId"
                        :label="college.collegeName"
                        :value="college.collegeId"
                      />
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="专业" prop="majorId">
                  <el-select
                      v-model="form.majorId"
                      placeholder="请选择专业"
                      clearable
                      size="small"
                      style="width: 200px"
                    >
                      <el-option
                        v-for="major in majorOptions"
                        :key="major.majorId"
                        :label="major.majorName"
                        :value="major.majorId"
                      />
                    </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="年级" prop="grade">
                  <el-input v-model="form.grade" placeholder="请输入年级" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="身份证号" prop="idNo">
                  <el-input v-model="form.idNo" placeholder="请输入身份证号" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="身份证正面" prop="idFrontUrl">
                  <img :src="form.idFrontUrl" >
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="身份证背面" prop="idBackUrl">
                  <img :src="form.idBackUrl" >
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="民族" prop="nation">
                  <el-select v-model="form.nation" placeholder="请选择民族">
                    <el-option
                        v-for="dict in nationOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="手机号" prop="cellNo">
                  <el-input v-model="form.cellNo" placeholder="请输入手机号" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="QQ号" prop="qqNo">
                  <el-input v-model="form.qqNo" placeholder="请输入QQ号" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="用户邮箱" prop="email">
                  <el-input v-model="form.email" placeholder="请输入用户邮箱" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="收费信息" name="third">
            <el-row>
              <el-col :span="12">
                <el-form-item label="缴费类型" prop="payType">
                  <el-select v-model="form.payType" placeholder="请选择缴费类型">
                    <el-option
                        v-for="dict in payTypeOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="缴费状态">
                  <el-select v-model="form.payStatus" placeholder="请选择缴费类型">
                    <el-option
                        v-for="dict in payStatusOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="分期数" prop="stageNum">
                  <el-input :disabled="!stageInputStatus" v-model="form.stageNum" placeholder="请输入分期数" />
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="分期金额" prop="stageAmount">
                  <el-input :disabled="!stageInputStatus" v-model="form.stageAmount" placeholder="请输入分期金额" />
                </el-form-item>
              </el-col>
            </el-row>
            <!-- 增加分期表数据 -->
            <!-- 系统能够自动催缴，不用做手工
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button style="margin-left:10px" type="cyan" icon="el-icon-search" size="mini" @click="urgedStage">催缴</el-button>
              </el-col>
            </el-row>
            -->
            <el-table ref="tableStage" v-loading="loading" :data="studentStageList" @selection-change="selectionChangeStageHandler">
              <el-table-column type="selection" width="55" align="center" />
              <el-table-column label="订单号" align="center" prop="orderNo" />
              <el-table-column label="缴费类型" align="center" prop="payType" />
              <el-table-column label="缴费状态" align="center" prop="payStatus" />
              <el-table-column label="分期数" align="center" prop="stageNum" />
              <el-table-column label="分期金额" align="center" prop="stageAmount" />
              <el-table-column label="缴费日期" align="center" prop="payDate" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.payDate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="到期日期" align="center" prop="stageDate" width="180">
                <template slot-scope="scope">
                  <span>{{ parseTime(scope.row.stageDate, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
              <el-table-column label="催缴状态" align="center" prop="urgedStatus" />
            </el-table>
            <pagination
              v-show="totalStage>0"
              :total="totalStage"
              :page.sync="queryParamsStage.pageNum"
              :limit.sync="queryParamsStage.pageSize"
              @pagination="getListStage"
            />
          </el-tab-pane>
          <el-tab-pane label="状态信息" name="fourth">
            <el-row>
              <el-col :span="12">
                <el-form-item label="学习类别" prop="trainType">
                  <el-select v-model="form.trainType" placeholder="请选择缴费类型">
                    <el-option
                        v-for="dict in trainTypeOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="帐号状态">
                  <el-select v-model="form.status" placeholder="请选择缴费类型">
                    <el-option
                        v-for="dict in statusOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="紧急联系人" name="fivth">
            <el-button size="mini" type="primary"
              icon="el-icon-plus" @click="addUrgent">新增联系人</el-button>
            <div style="margin: 15px 0;"></div>
            <el-row  style="margin-left: -115px;" v-for="(item,index) in urgentInfo" :key="index">
              <el-col :span="5">
                <el-form-item label="关系">
                  <el-select style="width:180px" 
                    v-model="item.urgentType" 
                    placeholder="请选择联系人关系">
                    <el-option
                        v-for="dict in urgentTypeOptions"
                        :key="dict.dictValue"
                        :label="dict.dictLabel"
                        :value="dict.dictValue"
                      >
                    </el-option>
                  </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="">
                  <el-input style="width:200px"  v-model="item.urgentName" placeholder="请输入联系人姓名" >
                    <template slot="prepend">姓名</template>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="5">
                <el-form-item label="">
                  <el-input style="width:200px"  v-model="item.cellNo" placeholder="请输入联系人电话" >
                    <template slot="prepend">电话</template>
                  </el-input>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                   <div style="text-align:center;">
                    <el-button size="mini" type="danger"
                      icon="el-icon-delete" v-if="urgentInfo.length > 1" 
                      @click="delUrgentInfo(index)">删除</el-button>
                   </div>
                 </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="跟进信息" name="sixth">
            <el-button size="mini" type="primary"
              icon="el-icon-plus" @click="addTraceInfo">新增跟进信息</el-button>
            <div style="margin: 15px 0;"></div>
            <el-row  style="margin-left: -115px;" v-for="(item,index) in tracingInfo" :key="index">
              <el-col :span="20">
                <el-form-item label="">
                  <el-input v-model="item.content" type="textarea" :rows="5" placeholder="请输入跟进内容"/>
                </el-form-item>
              </el-col>
              <el-col :span="4">
                   <div style="text-align:center;">
                    <el-button size="mini" type="danger"
                      icon="el-icon-delete" v-if="tracingInfo.length > 1" 
                      @click="delTraceInfo(index)">删除</el-button>
                   </div>
                 </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="选班信息" name="seventh">
            <el-row>
              <el-col :span="12">
                <el-form-item label="班级" prop="classId">
                  <el-select
                      v-model="form.classId"
                      placeholder="请选班级"
                      clearable
                      size="small"
                      style="width: 200px"
                    >
                      <el-option
                        v-for="classInfo in classOptions"
                        :key="classInfo.classId"
                        :label="classInfo.className"
                        :value="classInfo.classId"
                      />
                    </el-select>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="科别" prop="subjectType">
                  <el-select v-model="form.subjectType" placeholder="请选择科别">
                    <el-option
                          v-for="dict in subjectTypeOptions"
                          :key="dict.dictValue"
                          :label="dict.dictLabel"
                          :value="dict.dictValue"
                        ></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <!-- 增加历史选班列表查询 -->
            <el-table v-loading="loading" :data="classStudentList" @selection-change="handleSelectionClassStudentChange">
              <el-table-column label="班级" align="center" prop="className" />
              <el-table-column label="学生" align="center" prop="studentName" />
              <el-table-column label="开班状态" :formatter="classStatusFormat" align="center" prop="classStatus" />
            </el-table>
            <pagination
              v-show="totalCs>0"
              :total="totalCs"
              :page.sync="queryParamsCs.pageNum"
              :limit.sync="queryParamsCs.pageSize"
              @pagination="getClassStudentList"
            />
          </el-tab-pane>
        </el-tabs>
        
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="submitForm" v-show="showFlg" >确 定</el-button>
        <el-button size="mini" @click="cancel" v-show="showFlg">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog :title="title" :visible.sync="openStepIn" width="1000px" append-to-body>
      <el-form ref="formStepIn" :model="formStepIn" label-width="120px">
        <el-form-item label="校区" prop="campus">
          <treeselect style="width:200px" v-model="formStepIn.campusId" :options="campusOptions" 
                :multiple="false" :disableBranchNodes="true"
                :select="selectOthers"
                :show-count="true" placeholder="请选择归属校区" />
        </el-form-item>
        <el-form-item label="班级" prop="newClassId">
          <el-select
                v-model="formStepIn.newClassId"
                placeholder="请选班级"
                clearable
                size="small"
                style="width: 200px"
              >
                <el-option
                  v-for="classInfo in classOptions"
                  :key="classInfo.classId"
                  :label="classInfo.className"
                  :value="classInfo.classId"
                />
              </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="submitStepIn">确 定</el-button>
        <el-button size="mini" @click="cancelStepIn">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listStudent, listStudentOfficial, getStudent, graduateStudent, stepInStudent, delStudent, addStudent, updateStudent, exportStudent } from "@/api/edu/student";
import { listStudentStage  } from "@/api/edu/studentStage";
import { listClassStudent  } from "@/api/edu/classStudent";
import { getHSchools} from "@/api/edu/hSchools";
import { treeselectByType } from "@/api/system/dept";
import { listUserByDeptId } from "@/api/system/user";
import { listByDeptId } from "@/api/edu/hSchools";
import { getHCollegesBySchoolId } from "@/api/edu/hColleges";
import { getHMajorsByCollegeId } from "@/api/edu/hMajors";
import { ajaxList } from "@/api/edu/classInfo";
//import { listUrgentByStudentId } from "@/api/edu/urgent";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import ExtendedSelect from "@/components/ExtendedSelect";

export default {
  name: "Student",
  components: { Treeselect, ExtendedSelect },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 学生（客户）信息表格数据
      studentList: [],
      // 高级查询图标
      highQueryIcon: 'el-icon-arrow-down',
      // 高级查询标志
      highQueryFlag: false,
      activeName: 'first',
      statusOptions: [],
      // 校区数据
      campusOptions: [],
      schoolOptions: [],
      collegeOptions: [],
      majorOptions: [],
      classOptions: [],
      // 招生员
      recruitUserOptions: [],
      subjectTypeOptions: [],
      payTypeOptions: [],
      payStatusOptions: [],
      trainTypeOptions: [],
      studentTypeOptionsL: [],
      nationOptions: [],
      sexOptions: [],
      urgentInfo: [{
        urgentType: null,
        urgentName: null,
        cellNo: null,
      }],
      urgentTypeOptions: [],
      tracingInfo: [{
        userId: null,
        content: null
      }],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      openStepIn: false,
      stepInStudentIds: null,
      stageInputStatus: true, // 分期信息输入框
      showFlg: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        studentNo: null,
        studentName: null,
        campusId: null,
        schoolId: null,
        collegeId: null,
        majorId: null,
        classId: null,
        grade: null,
        subjectType: null,
        studentType: null,
        idNo: null,
        nation: null,
        cellNo: null,
        qqNo: null,
        wxOpenId: null,
        email: null,
        sex: null,
        avatar: null,
        addr: null,
        urgentPerson: null,
        urgentCellNo: null,
        password: null,
        marketingSource: null,
        recruitUserId: null,
        inputUserId: null,
        auditUserId: null,
        registDate: null,
        payType: null,
        payStatus: null,
        stageNum: null,
        stageAmount: null,
        trainType: null,
        status: null,
        loginIp: null,
        loginDate: null,
      },
      campusIdForm: null,
      // 表单参数
      form: {},
      formStepIn: {},
      // 分期缴费列表
      studentStageList: [],
      totalStage: 0,
      queryParamsStage: {
        pageNum: 1,
        pageSize: 10,
        studentId: null,
      },
      // 选班列表
      classStudentList: [],
      classStatusOptions: [],
      totalCs: 0,
      queryParamsCs: {
        pageNum: 1,
        pageSize: 10,
        studentId: null,
      },
      // 表单校验
      rules: {
        /*
        studentNo: [
          { required: true, message: "学号不能为空", trigger: "blur" }
        ],
        */
        studentName: [
          { required: true, message: "学生姓名不能为空", trigger: "blur" }
        ],
        schoolId: [
          { required: true, message: "学校ID不能为空", trigger: "blur" }
        ],
        collegeId: [
          { required: true, message: "学院ID不能为空", trigger: "blur" }
        ],
        majorId: [
          { required: true, message: "专业ID不能为空", trigger: "blur" }
        ],
        /*
        classId: [
          { required: true, message: "班级ID不能为空", trigger: "blur" }
        ],
        */
        grade: [
          { required: true, message: "年级不能为空", trigger: "blur" }
        ],
        idNo: [
          { required: true, message: "身份证号不能为空", trigger: "blur" }
        ],
        nation: [
          { required: true, message: "民族不能为空", trigger: "blur" }
        ],
        cellNo: [
          { required: true, message: "手机号不能为空", trigger: "blur" }
        ],
        qqNo: [
          { required: true, message: "QQ号不能为空", trigger: "blur" }
        ],
        /*
        urgentPerson: [
          { required: true, message: "紧急联系人不能为空", trigger: "blur" }
        ],
        urgentCellNo: [
          { required: true, message: "紧急联系电话不能为空", trigger: "blur" }
        ],
        marketingSource: [
          { required: true, message: "营销来源不能为空", trigger: "blur" }
        ],
        */
        recruitUserId: [
          { required: true, message: "招生员ID不能为空", trigger: "blur" }
        ],
        /*
        inputUserId: [
          { required: true, message: "录入人ID不能为空", trigger: "blur" }
        ],
        auditUserId: [
          { required: true, message: "审核人ID不能为空", trigger: "blur" }
        ],
        */
        stageNum: [
          { required: true, message: "分期数不能为空", trigger: "blur" }
        ],
        stageAmount: [
          { required: true, message: "分期金额不能为空", trigger: "blur" }
        ],
      }
    };
  },
  created() {
    // 0 游客， 1 注册客户， 2 预报名， 3 学员， 00，查所有
    this.queryCampus();
    this.getDicts("sys_normal_disable").then(response => {
      this.statusOptions = response.data;
    });
    this.getDicts("edu_subject_type").then(response => {
      this.subjectTypeOptions = response.data;
    });
    this.getDicts("edu_pay_type").then(response => {
      this.payTypeOptions = response.data;
    });
    this.getDicts("edu_pay_status").then(response => {
      this.payStatusOptions = response.data;
    });
    this.getDicts("edu_train_type").then(response => {
      this.trainTypeOptions = response.data;
    });
    this.getDicts("edu_student_type").then(response => {
      this.studentTypeOptions = response.data
    })
    this.getDicts("edu_urgent_type").then(response => {
      this.urgentTypeOptions = response.data
    })
    this.getDicts("sys_nation").then(response => {
      this.nationOptions = response.data
    })
    this.getDicts("sys_user_sex").then(response => {
      this.sexOptions = response.data
    })
    this.getDicts("edu_class_status").then(response => {
      this.classStatusOptions = response.data
    })
    this.getList();
  },
  watch: {
    'queryParams.campusId': 'selectOthers',
    'campusIdForm': 'selectOthersForm',
    'form.schoolId': 'selectCollege',
    'form.collegeId': 'selectMajors',
    'formStepIn.campusId': 'selectStepInForm',
    'form.payType': 'setStageInfo',
  },
  methods: {
    /** 查询学生（客户）信息列表 */
    getList() {
      this.loading = true;
      listStudentOfficial(this.queryParams).then(response => {
        this.studentList = response.rows;
        //console.log(JSON.stringify(this.studentList))
        this.total = response.total;
        this.loading = false;
      });
    },
    queryCampus() {
      // 查询校区（deptType = 1）
      treeselectByType("1").then(response => {
        this.campusOptions = response.data;
      })
    },
    selectOthers() {
      this.queryHSchool(this.queryParams.campusId);
      this.queryRecruitUser(this.queryParams.campusId);
      this.queryClassInfo(this.queryParams.campusId);
    },
    // 新增界面
    selectOthersForm() {
      // 重新选择校区时，将学校、学院、专业、招生老师重置，需重新设置
      this.form.schoolId = null
      this.form.collegeId = null
      this.form.majorId = null
      this.form.recruitUserId = null
      
      this.queryHSchool(this.campusIdForm);
      this.queryRecruitUser(this.campusIdForm);
      this.queryClassInfo(this.campusIdForm);
    },
    selectStepInForm() {
      this.queryClassInfo(this.formStepIn.campusId);
    },
    queryHSchool(campusId) {
      if(campusId === undefined || campusId === null) {
        this.$message({
            type: 'warning',
            message: '请选择校区'
          })
          return
      }
      
      listByDeptId(parseInt(campusId)).then(response => {
        //console.log(response.data)
        this.schoolOptions = response.data
      })
      
    },
    queryRecruitUser(campusId) {
      if(campusId === undefined || campusId === null) {
        this.$message({
            type: 'warning',
            message: '请选择校区'
          })
          return
      }
      listUserByDeptId(campusId).then(response => {
        this.recruitUserOptions = response.data
      })
    },
    queryClassInfo(campusId) {
      if(campusId === undefined || campusId === null) {
        this.$message({
            type: 'warning',
            message: '请选择校区'
          })
          return
      }
      let classInfo = {
        campusId : campusId
      }
      ajaxList(classInfo).then(response => {
        this.classOptions = response.data
      })
    },
    selectCollege() {
      if(this.form.schoolId === undefined || this.form.schoolId === null) {
        this.$message({
            type: 'warning',
            message: '请选择校区'
          })
          return
      }
      getHCollegesBySchoolId(this.form.schoolId).then(response => {
        this.collegeOptions = response.data
      })
    },
    selectMajors() {
      if(this.form.collegeId === undefined || this.form.collegeId === null) {
        this.$message({
            type: 'warning',
            message: '请选择校区'
          })
          return
      }
      getHMajorsByCollegeId(this.form.collegeId).then(response => {
        this.majorOptions = response.data
      })
    },
    // 字典状态字典翻译
    statusFormat(row, column) {
      return this.selectDictLabel(this.statusOptions, row.status);
    },
    subjectTypeFormat(row, column) {
      return this.selectDictLabel(this.subjectTypeOptions, row.subjectType);
    },
    payTypeFormat(row, column) {
      return this.selectDictLabel(this.payTypeOptions, row.payType);
    },
    payStatusFormat(row, column) {
      return this.selectDictLabel(this.payStatusOptions, row.payStatus);
    },
    trainTypeFormat(row, column) {
      return this.selectDictLabel(this.trainTypeOptions, row.trainType);
    },
    studentTypeFormat(row, column) {
      return this.selectDictLabel(this.studentTypeOptions, row.studentType);
    },
    nationFormat(row, column) {
      return this.selectDictLabel(this.nationOptions, row.nation);
    },
    sexFormat(row, column) {
      return this.selectDictLabel(this.sexOptions, row.sex);
    },
    classStatusFormat(row, column) {
      return this.selectDictLabel(this.classStatusOptions, row.classStatus);
    },
    // 删除选择部门数据
    closeOnSelect() {
      //this.form.depts = []
      this.form.deptIds = []
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    highQuery() {
      this.highQueryFlag = !this.highQueryFlag
      if(this.highQueryIcon === 'el-icon-arrow-down' ) {
        this.highQueryIcon = 'el-icon-arrow-up'
        
      } else {
        this.highQueryIcon = 'el-icon-arrow-down'
        // 隐藏查询条件不展示
        let studentNo = this.queryParams.studentNo
        let studentName = this.queryParams.studentName
        let cellNo = this.queryParams.cellNo
        this.resetForm("queryForm");
        this.queryParams.studentNo = studentNo
        this.queryParams.studentName = studentName
        this.queryParams.cellNo = cellNo
      }
    },
    // 表单重置
    reset() {
      this.urgentInfo = [{
        urgentType: null,
        urgentName: null,
        cellNo: null,
      }],
      this.tracingInfo = [{
        userId: null,
        content: null
      }],

      this.form = {
        studentId: null,
        studentNo: null,
        studentName: null,
        schoolId: null,
        schoolName: null,
        collegeId: null,
        collegeName: null,
        majorId: null,
        majorName: null,
        classId: null,
        className: null,
        grade: null,
        subjectType: null,
        studentType: null,
        idFrontUrl: null,
        idBackUrl: null,
        idNo: null,
        nation: null,
        cellNo: null,
        qqNo: null,
        wxOpenId: null,
        email: null,
        sex: null,
        avatar: null,
        addr: null,
        urgentPerson: null,
        urgentCellNo: null,
        password: null,
        marketingSource: null,
        recruitUserId: null,
        inputUserId: null,
        auditUserId: null,
        recruitUserName: null,
        inputUserName: null,
        auditUserName: null,
        registDate: null,
        payType: null,
        payStatus: "0",
        stageNum: null,
        stageAmount: null,
        trainType: null,
        status: "0",
        delFlag: null,
        loginIp: null,
        loginDate: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null,
        eduStudentUrgentList: null,
        eduStudentTracingList: null,
      };
      this.resetForm("form");
    },
    resetStepIn() {
      this.formStepIn = {
        campusId: null,
        newClassId: null,
        oldClassId: null
      }
      this.resetForm("formStepIn");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.studentId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.showFlg = true;
      this.title = "添加学生信息";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      // 获取学校对应的校区
        let schoolId = row.schoolId
        if(undefined !== schoolId && null !== schoolId && "" !== schoolId) {
          getHSchools(schoolId).then(response => {
            this.campusIdForm = response.data.deptId
          })
        }

      const studentId = row.studentId || this.ids
      getStudent(studentId).then(response => {
        this.form = response.data;
        this.open = true;
        this.showFlg = true;
        this.title = "修改学生信息";

        // 先初始化tab数据  避免出现直接保存   没有切换的情况
        if(this.form.eduStudentUrgentList.length > 0 ) {
          this.urgentInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentUrgentList.forEach(urgent => {
            this.urgentInfo.push({
              urgentType: urgent.urgentType,
              urgentName: urgent.urgentName,
              cellNo: urgent.cellNo,
            })
          })
        }

        if(this.form.eduStudentTracingList.length > 0) {
          this.tracingInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentTracingList.forEach(tracing => {
            this.tracingInfo.push({
              userId: tracing.userId,
              content: tracing.content
            })
          })
        }
      });
    },
    /** 学员名字操作 */
    handleReference(row) {
      this.reset();
      this.showFlg = false;
      const studentId = row.studentId || this.ids
      getStudent(studentId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "参照学生信息";

        // 先初始化tab数据  避免出现直接保存   没有切换的情况
        if(this.form.eduStudentUrgentList.length > 0 ) {
          this.urgentInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentUrgentList.forEach(urgent => {
            this.urgentInfo.push({
              urgentType: urgent.urgentType,
              urgentName: urgent.urgentName,
              cellNo: urgent.cellNo,
            })
          })
        }

        if(this.form.eduStudentTracingList.length > 0) {
          this.tracingInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentTracingList.forEach(tracing => {
            this.tracingInfo.push({
              userId: tracing.userId,
              content: tracing.content
            })
          })
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.eduStudentUrgentList = []
          this.urgentInfo.forEach(option =>{
            this.form.eduStudentUrgentList.push({
                urgentType: option.urgentType,
                urgentName: option.urgentName,
                cellNo: option.cellNo,
              })
          })

          // tracingInfo
          this.form.eduStudentTracingList = []
          this.tracingInfo.forEach(option => {
            this.form.eduStudentTracingList.push({
              userId: option.userId,
              content: option.content
            })
          })

          if (this.form.studentId != null) {
            updateStudent(this.form).then(response => {
              this.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addStudent(this.form).then(response => {
              this.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const studentIds = row.studentId || this.ids;
      this.$confirm('是否确认删除学生（客户）信息编号为"' + studentIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delStudent(studentIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        })
    },
    handleUpgrade(row) {
      const studentIds = row.studentId || this.ids;
      // 暂时没加这个功能
    },
    handleGraduate(row) {
      const studentIds = row.studentId || this.ids;
      this.$confirm('是否允许结业？', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          graduateStudent(studentIds)
        }).then(() => {
          this.getList();
          this.msgSuccess("结业成功");
        })
     
    },
    // 插班/换班
    handleClassStepIn(row) {
      this.resetStepIn()
      this.stepInStudentIds = row.studentId || this.ids;
      this.openStepIn = true
      this.title = "插班/换班"
    },
    submitStepIn() {
      // 调后端
      stepInStudent(this.stepInStudentIds, this.formStepIn).then(response => {
        this.msgSuccess("插班/换班成功");
        this.open = false;
        this.stepInStudentIds = null
        this.getList();
      })
    },
    cancelStepIn() {
      this.resetStepIn()
      this.openStepIn = false
      this.stepInStudentIds = null
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有学生信息数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportStudent(queryParams);
        }).then(response => {
          this.download(response.msg);
        })
    },
    handleTabChange() {
      if("fivth" === this.activeName) {
        if(this.form.eduStudentUrgentList.length > 0 ) {
          this.urgentInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentUrgentList.forEach(urgent => {
            this.urgentInfo.push({
              urgentType: urgent.urgentType,
              urgentName: urgent.urgentName,
              cellNo: urgent.cellNo,
            })
          })
        }
        
      } else {
        // 切换tab时需要临时保存数据
        if(this.urgentInfo.length > 0) {
          this.form.eduStudentUrgentList = []
          this.urgentInfo.forEach(option =>{
            this.form.eduStudentUrgentList.push({
                urgentType: option.urgentType,
                urgentName: option.urgentName,
                cellNo: option.cellNo,
              })
          })
        }
          
        if(this.tracingInfo.length > 0) {
          // tracingInfo
          this.form.eduStudentTracingList = []
          this.tracingInfo.forEach(option => {
            this.form.eduStudentTracingList.push({
              userId: option.userId,
              content: option.content
            })
          })
        }
      }

      if("sixth" === this.activeName) {
        if(this.form.eduStudentTracingList.length > 0) {
          this.tracingInfo = []//.splice(0,1) // 删除原来的空行
          this.form.eduStudentTracingList.forEach(tracing => {
            this.tracingInfo.push({
              userId: tracing.userId,
              content: tracing.content
            })
          })
        }
      } else {
        // 切换tab时需要临时保存数据
        if(this.urgentInfo.length > 0) {
          this.form.eduStudentUrgentList = []
          this.urgentInfo.forEach(option =>{
            this.form.eduStudentUrgentList.push({
                urgentType: option.urgentType,
                urgentName: option.urgentName,
                cellNo: option.cellNo,
              })
          })
        }
          
        if(this.tracingInfo.length > 0) {
          // tracingInfo
          this.form.eduStudentTracingList = []
          this.tracingInfo.forEach(option => {
            this.form.eduStudentTracingList.push({
              userId: option.userId,
              content: option.content
            })
          })
        }
      }

      if("third" === this.activeName) {
        this.getListStage()
      }

      if("seventh" === this.activeName) {
        this.getClassStudentList()
      }
    },
    addUrgent() {
      this.urgentInfo.push({
        urgentType: null,
        urgentName: null,
        cellNo: null,
      })
    },
    delUrgentInfo(index) {
      if(this.urgentInfo.length > 1) {
        this.urgentInfo.splice(index,1)
      } else {
        this.msgError("至少有一个联系人");
      }
    },
    addTraceInfo() {
      this.tracingInfo.push({
        userId: null,
        content: null,
      })
    },
    delTraceInfo(index) {
      if(this.tracingInfo.length > 1) {
        this.tracingInfo.splice(index,1)
      } else {
        this.msgError("至少有一个跟进信息");
      }
    },
    // 获取分期信息
    getListStage() {
      if(!this.form.studentId) {
        return
      }
      this.queryParamsStage.studentId = this.form.studentId
      this.loading = true;
      listStudentStage(this.queryParamsStage).then(response => {
        this.studentStageList = response.rows;
        this.totalStage = response.total;
        this.loading = false;
      });
    },
    selectionChangeStageHandler() {

    },
    setStageInfo() {
      // 设置分期信息输入框编辑状态
      if('0' === this.form.payType) {
        this.stageInputStatus = false
        this.form.stageNum = 0
        this.form.stageAmount = 0
      } else {
        this.stageInputStatus = true
      }
    },
    getClassStudentList() {
      if(!this.form.studentId) {
        return
      }
      this.queryParamsCs.studentId = this.form.studentId
      this.loading = true;
      listClassStudent(this.queryParamsCs).then(response => {
        this.classStudentList = response.rows;
        this.totalStage = response.total;
        this.loading = false;
      });
    },
    handleSelectionClassStudentChange() {

    },
  }
};
</script>
